package caen.finder;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import android.app.Activity;
import android.os.Bundle;
import javax.xml.parsers.*;
import javax.xml.*;
import org.w3c.dom.*;
import org.xml.sax.SAXException;

public class CAENFinderActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        String url = "http://caen-php-test.engin.umich.edu/api/beta/computers.xml";
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = null;
		try {
			db = dbf.newDocumentBuilder();
		} catch (ParserConfigurationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Document doc = null;
        try {
			doc = db.parse(new URL(url).openStream());
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SAXException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Element root = doc.getDocumentElement();
		NodeList computers = root.getElementsByTagName("computers");
		NodeList available = root.getElementsByTagName("in_use");
		for(int i = 0; i < computers.getLength(); i++)
		{
			Element somComp = (Element)computers.item(i);
		}
    }
}